package com.learn.aop.interceptor;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import lombok.extern.slf4j.Slf4j;

/**
 * @description: java类作用描述
 * @author: MI
 * @email: 448341911@qq.com
 * @createTime: 2024/1/7 21:32
 * @updateUser: cong zhi
 * @updateTime: 2024/1/7 21:32
 * @updateRemark: 修改内容
 * @version: v1.0
 */
@Slf4j
public class TimeCostMethodInterceptor implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        Object result;
        long startTime = System.currentTimeMillis();
        try {
            result = invocation.proceed();
        } finally {
            log.info(">>>>>>>>>>>>>>>>>>>>>>>>{} costTime:【{}】 ms", invocation.getMethod().getName(), (System.currentTimeMillis() - startTime));
        }

        return result;
    }
}